FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src

#提高打包速度
COPY ./CHDotNetCli.csproj /src/CHDotNetCli/ 
RUN dotnet restore "/src/CHDotNetCli/CHDotNetCli.csproj"

COPY . . /src/CHDotNetCli/
WORKDIR "/src/CHDotNetCli"
RUN dotnet build "CHDotNetCli.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "CHDotNetCli.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
CMD ["dotnet", "CHDotNetCli.dll"]
